package cn.t.keycloak.plugin.login.rest;

import org.keycloak.Config;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.services.resource.RealmResourceProvider;
import org.keycloak.services.resource.RealmResourceProviderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 自定义endpoint首先需要实现RealmResourceProviderFactory接口,提供provider工厂
 * @author 陶敏麒
 * @date 2023/11/7 10:04
 */
public class DemoRestProviderFactory implements RealmResourceProviderFactory {

    private static final Logger log = LoggerFactory.getLogger(DemoRestProviderFactory.class);
    private static final String ID = "demo-rest-provider";
    @Override
    public RealmResourceProvider create(KeycloakSession keycloakSession) {
        return new DemoRestProvider(keycloakSession);
    }

    @Override
    public void init(Config.Scope scope) {
        log.info(">>>>>DemoRestProviderFactory开始初始化");
    }

    @Override
    public void postInit(KeycloakSessionFactory keycloakSessionFactory) {

    }

    @Override
    public void close() {

    }

    @Override
    public String getId() {
        return ID;
    }
}
